<%@page import="com.df.springmvc.system.manage.controller.IndexController"%>
<%@page import="com.common.util.Date.DateUtil"%>

<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" %>    
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	request.setAttribute("currentDate", DateUtil.getInstance());
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>首页</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link href="image/favicon1.ico" rel="shortcut icon">

<jsp:include page="/scripts/common/index.html"></jsp:include>
<jsp:include page="/scripts/dhtmlx/index.html"></jsp:include>
<jsp:include page="/scripts/jquery/index.html"></jsp:include>
<jsp:include page="/scripts/bootstrap/index.html"></jsp:include>
<link rel="stylesheet" href="${basePath }style/index.css">
<link rel="stylesheet" href="${basePath }style/default.css">

<style>
.portal1 {
	position: relative;
	width: 23%;
	height: 95%;
	float: left;
	left: 1%;
	top: 5%;
	border: 1px solid #0099cc;
	background: #ffffff /*-moz-transform: rotate(-5deg); -webkit-transform: rotate(-5deg); -ms-transform: rotate(-5deg); transform: rotate(-5deg);*/
}

.portal2 {
	position: relative;
	width: 23%;
	height: 95%;
	float: left;
	left: 3%;
	top: 5%;
	border: 1px solid #0099cc;
	background: #ffffff
}

.portal3 {
	position: relative;
	width: 23%;
	height: 95%;
	float: left;
	left: 5%;
	top: 5%;
	border: 1px solid #0099cc;
	background: #ffffff
}

.portal4 {
	position: relative;
	width: 23%;
	height: 95%;
	float: left;
	left: 7%;
	top: 5%;
	border: 1px solid #0099cc;
	background: #ffffff
}
.btn-active {
	color: #0099cc;
	background-color: #ffffff;
	border-radius: 0px !important;
}
</style>
<script type="text/javascript">
	function checkLogin() {
		var url = '${basePath}page/system/manage/Login/checkLogin';
		var data = {};
		$.ajax({
				type : 'POST' ,
				url : url ,
				data : data ,
				dataType : "json" ,
				async : true ,
				cache : false ,
				jsonpCallback : "jsonpCallback" ,
				success : function(response, status, statusText) {
					//alert(response + ":" + status + ":" + statusText);
					if (response.status == false) {
						alert("会话失效，请重新登录 。");
						top.location.href = "${basePath}";
					}
				}
		});
	}
	$(function() {
		setInterval("checkLogin()", 1000 * 60);
		//function listClick(id, name, url, icon) {
		listClick("index", "首页", "${basePath}page/bi/home/tohome", "");
		$("#isshow").hide();
		//listClick("index", "首页", "${basePath}page/system/manage/Index/toPortlet", "");
		//setInterval(listClick("index", "首页", "${basePath}page/system/manage/Index/toPortlet", ""), 1000);
	});
	function logout() {
		//1.加密 
		var str = '确认注销？'; 
		var base = new Base64(); 
		var result = base.encode(str); 
	
		SN.alert.confirm(result, function(obj) {
			if (obj) {
				$.ajax({
						type : 'POST' ,
						url : 'page/system/manage/Logout/doLogout' ,
						data : {} ,
						dataType : "json" ,
						async : true ,
						cache : false ,
						jsonpCallback : "null" ,
						success : function(response, status, statusText) {
							//alert(response + ":" + status + ":" + statusText);
							if (response.status) {
								var result2 = base.encode("您已成功注销!"); 
							
								SN.alert.info(result2, function() {
									window.location.reload();
								});
							} else {
								alert(response.content);
							}
						} ,
						error : function(response, status, statusText) {
							//alert(response + ":" + status + ":" + statusText);
						} ,
						complete : function(response, status, statusText) {
							//alert(response + ":" + status + ":" + statusText);
						}
				});
			}
		});
	} 
	$(function() {
		initMenu();
		//menuWidth();
		$("#tabBtn").click(function() {
			
			var X = $("#tabBtn").offset().top +25;
			var Y = $("#tabBtn").offset().left;
			if (document.getElementById("tabDiv").style.display == "" || document.getElementById("tabDiv").style.display == "none") {
				
				$("#tabDiv").css("top", "" + X + "");
				$("#tabDiv").css("left", "" + Y + "");
				$("#tabDiv").show();
				/* var breadcrumbcont = $("<li class='active' title='tab'>已激活页面</li>");
				var breadcrumb = $("#breadcrumb");
				breadcrumb.append(breadcrumbcont);  */
			} else {
				$("#tabDiv").hide();
				
			}
		});
		$("#closeTabDiv").click(function() {
			$("#tabDiv").hide();
		});
		/* document.getElementById("myframe").src = "${bastpath }page1/system/Role_Privileges.jsp"; */
	});
	//加载菜单
	function initMenu() {
		var menu = [ ];
		var url = '${basepath}page/system/manage/Index/getMenuJson';
		var data = {};
		$.ajax({
				type : 'POST' ,
				url : url ,
				data : data ,
				dataType : "json" ,
				async : false ,
				cache : false ,
				jsonpCallback : "jsonpCallback" ,
				success : function(response, status, statusText) {
					//	alert(response + ":" + status + ":" + statusText);
					if (response.status) {
						var json = response.content;
						console.debug(json);
						menu = json;
					} else {
						alert(response.content);
					}
				}
		});
		var createMenu = "";
			var bodyWidth=$("#mainBody").css("width").replace("px","")-35;
		for ( var i = 0; i < menu.length; i++) {//第一级
			var menuName = menu[i].name;
			var menuId = menu[i].id;
			createMenu += "<div id='menu' class='dropdown dropdownStyle' style='float:left;left:5px;top:10%;'>";
			var menuClick = menu[i].url;
			var icon=menu[i].icon;
			//createMenu += "<span class='caret'><a onmouseover='movesryle()' onmouseout='moveout()' onclick='listClick(\"" + getNewId() + "\",\"" + childName + "\",\"" + menuClick + "\",\"" + icon + "\")'  ><span style='overflow:hidden;width:120px;display:inline-block;display:-moz-inline-box;margin-bottom:-5px;'>" + childName + "</span></a>&nbsp;</span>";
			createMenu += "<button class='btn btn-default dropdown-toggle' style='border:0px;margin-top:5px;margin-left:2px;border-radius: none' type='button'   onclick='listClick(\"" + i + "\",\"" + menuName + "\",\"" + menuClick + "\",\"" + icon + "\")'  >";
			createMenu += menuName + " <span class=''></span>";
			createMenu += "</button>";
			createMenu += "<ul class='dropdown-menu' aria-labelledby='dropdownMenu1' style=' position:absolute;top:30px;width: "+bodyWidth+";max-width:"+bodyWidth+";'>";
			createMenu += "<li>";
			createMenu += "<div style='height:98%;margin-left:4px;margin-bottom:5px;width:100%;'>";
			createMenu += "<table id='menuTable' style='height:100%;width: "+bodyWidth+";height:auto;max-width:"+bodyWidth+";' border='0' class='menuTab'>";
			
			createMenu += "</table>";
			createMenu += "</div>";
			createMenu += "</li>";
			createMenu += "</ul>";
			createMenu += "</div>";
		}
		document.getElementById("menuDiv").innerHTML = createMenu;
		var buttons = $("#menuDiv").find(".btn");
		
		buttons.bind("click",function (){
			$(this).addClass("btn-active")
			$(this).parent().siblings().find(".btn").removeClass("btn-active")
			
		
		})
		

		
	}
	var index = 1;
	function getNewId() {
		return index++;
	}
/*	function menuWidth() {
		var menuTab = document.getElementById("menuTable").children[0].children;
		var strlength = 0;
		var tableWidth = 0;
		var oldWidth = 0;
		for ( var i = 0; i < menuTab.length; i++) {
			tableWidth = 0;
			var menuTd = menuTab[i].children[3].children;
			for ( var j = 0; j < menuTd.length; j++) {
				strlength = menuTd[j].innerHTML.length;
				tableWidth = parseInt(tableWidth) + parseInt(22) + (parseInt(10) * parseInt(strlength));
			}
			tableWidth = parseInt(tableWidth) + parseInt(110) + (parseInt(6) * parseInt(menuTd.length));
			if (parseInt(oldWidth) < parseInt(tableWidth)) {
				oldWidth = tableWidth;
			}
		}
		if (parseInt(oldWidth) > 900) {
			oldWidth = "900";
		}
		document.getElementById("menuTable").style.width = oldWidth + "px";
	}   */
	function mouseover(obj) {
		obj.children[2].children[0].style.display = "";
	}
	function mouseout(obj) {
		obj.children[2].children[0].style.display = "none";
	}
	function colseFrame(id) {
		$("#span_" + id).remove();
		$("#myframes_" + id).remove();
		$("#myframes .myframes").each(function(k, o) {
			if (k == 0) {
				$("#" + o.id).show();
			} else {
				$("#" + o.id).hide();
			}
		});
		$("#tabDiv").hide();
	}

	function chageFrame(id) {
		if(id=="index"){
			$("#breadcrumb>li").filter(function(index){
				return index!=0;
				}).remove();
			//setInterval(listClick("index", "首页", "${basePath}page/system/manage/Index/toPortlet", ""), 1000);
			//setTimeout( abc(),10000); 
		}else{
			$("#breadcrumb>li").filter(function(index){
				return index!=0;
				}).remove();
			var name = $("#span_"+id).find("div").find("span").text();
			$("#breadcrumb").append("<li class='active' id='currentPath'>"+name+"</li>");
		}
		$("#myframes .myframes").each(function(k, o) {
			if ("myframes_" + id == o.id) {
				$("#" + o.id).show();
				$("#tabDiv").hide();
			} else {
				$("#" + o.id).hide();
			}
		});
	}
	var bcolorGroup = ["#6F5499","#0769AD","#4CAF50","#CF4646","#3498DB","#F0DB4F","#6FA67A","#D30D15",
	                   "#F43C12","#C3522F","#1ABC9C","#6D3353","#D35400","#1A2B33","#B9CFC1","#C47F3E",
	                   "#BF1813","#8E44AD","#4EADC4","#F05033"];
	
	
	//随机取不相同的颜色
	function getColorValue(tmp,val){
		for(var i=0; i<tmp.length; i++) {
	    	if(tmp[i] == bcolorGroup[val]) {
	    		return "false";
		    }
		}
		  return "true";
		}
	function movesryle(){
		var val = Math.floor(Math.random() * bcolorGroup.length);
		var bcolor =bcolorGroup[val];
		$(".menuCont a:hover").css({"background-color": "#bfc2c5"});
	}
	function moveout(){
	$(".menuCont a").css({background: "#ffffff" });
	}
	function listClick(id, name, url, icon) {
		$("#isshow").show();
		var isNew = true;
		var count_ = 0;
		$("#myframes .myframes").each(function(k, o) {
			if ("myframes_" + id == o.id) {
				isNew = false;
			}
			count_++;
		});
		if (isNew) {
			if (count_ >= 100) {
				alert("最多打开100个。请关闭不用的窗口后，重新打开。");
			} else {
				if (true) {
					var html = $("#myframesDemo").html();
					html = html.replace('id="_"', 'id="myframes_' + id + '"');
					
					html = html.replace('src="" ', 'src="' + url + '"');
					$("#myframes").append(html);
					
				}
				if (true) {
					var html = $("#DivModel").html();
					html = html.replace(/#ID#/g, id);
					var l = name.length;
					if (l > 12) {
						var name = name.substring(0,10)+"...";
					}
					html = html.replace(/#NAME#/g, name);
					$("#currentFrame").append(html);
				}
			}
		}
		var tmp = new Array();
		$("#currentFrame .bcolor").each(function(k, o) {
			var bcolor="";
			do{
				var val = Math.floor(Math.random() * bcolorGroup.length);
				bcolor =bcolorGroup[val];
			}
			while (getColorValue(tmp,val)!="true")
			tmp.push(bcolor);
			$(this).css("background-color",bcolor);
		});
		
		$("#myframes .myframes").each(function(k, o) {
			if ("myframes_" + id == o.id) {
				isNew = false;
				$("#" + o.id).show();
			} else {
				$("#" + o.id).hide();
			}
			count_++;
		});

		$("#breadcrumb>li").filter(function(index){
			return index!=0;
			}).remove();
		if(name!="首页"){
			//$("#breadcrumb").append("<li class='active' id='currentPath'>"+name+"</li>");
		}
	}
</script>
<script type="text/javascript">
function search(){
	$("#myframes_search").remove();
	var url = '${basepath}page/system/manage/Search/';
	var html = $("#myframesDemo").html();
	html = html.replace('id="_"', 'id="myframes_search"');
	html = html.replace('src="" ', 'src="' + url + '"');
	$("#myframes").append(html);
	var count_ = 0;
	$("#myframes .myframes").each(function(k, o) {
		if ("myframes_search" == o.id) {
			isNew = false;
			$("#" + o.id).show();
		} else {
			$("#" + o.id).hide();
		}
		count_++;
	});
}
$(function() {
	//个人信息
	$("#currenUser").click(function() {
		var v1 = $("#fullname").val();
		if(v1=="admin"){
			
		}else{
			SN.getWindowByUrl("个人信息", "850", "500", "${basePath}page/system/manage/Index/toPersonalInfo", {
				"fullname" : v1
			});
		}
	});
	
	$("#currenId").click(function() {
		var v1 = $("#fullname").val();
		if(v1=="admin"){
			
		}else{
			SN.getWindowByUrl("个人信息", "850", "500", "${basePath}page/system/manage/Index/toPersonalInfo", {
				"fullname" : v1
			});
		}
	});
	//消息
	$("#Message1").click(function() {
		SN.getWindowByUrl("消息", "850", "500", "${basePath}page/system/manage/Index/toMessage", {});
	});
	$("#Message2").click(function() {
		SN.getWindowByUrl("消息", "850", "500", "${basePath}page/system/manage/Index/toMessage", {});
	});
});
function updPassword(){
	SN.getWindowByUrl("修改密码", "450", "300", "${basePath}page/system/manage/Index/toUpdPassword", {});
}
</script>
<script type="text/javascript">
function init(){
	initMessageNum();
}

$(function(){setInterval(function() { initMessageNum()}, 1000*60);});

function initMessageNum(){
	
}


</script>
<script type="text/javascript">
/*   
  $(function(){
	  
	  setTimeout('myrefresh()',1000); 
	  });
 */
 </script>
<style type="text/css">
.menuCont a:hover{
color: white;
padding: 5px 10px 5px 10px;
border-radius: 3px;
text-decoration: none;
font-size: 12px;
outline: none;
}

.dropdownStyle{
position: inherit;
}
#menuTable{
}
#currenUser,#currenId,#Message1,#Message2{
cursor: pointer;
}
</style>
</head>
<body onload="init()" style="background:#ffffff;margin: 0px;width:100%;height:100%" >
	<div class="container-fluid" id="mainBody" style="height:100%;width:100%;min-width:1366px;max-width:1920px;margin:auto">
		<div class="row" style="height:60px;max-height:75px;min-height:60px;background:#ffffff;border-bottom:0px solid #0178b8">
			<div class="col-lg-12 col-md-12 col-sm-12 col-xs-18" style="border:0px solid #5479d7;height:100%;">
				<table style="width:100%;height:100%">
					<tr>
						<td style="width:50%;height:100%">
							<img src="${basepath}image/logo1.jpg" style="width:60px;max-height:60px;min-height:50px;height:50px;margin-left:5%;" />
							<%-- <img src="${basepath}image/productName.png" style="width:47.7%;max-width:400px" /> --%>
							<span style="color:#0099cc;font-weight:bold;font-size:32px;position:relative;left:50px">信息资源应用门户</span>
						</td>
						<td style="width:45%" align="right">
							<span style="color:#000000;font-size:14px;position:relative;top:5px">
								<span id="currenUser" class="glyphicon glyphicon-user" aria-hidden="true"></span>
								<span id="currenId">&nbsp;&nbsp;登录用户：${CurrentUserBean.fullname } 
								<input type="hidden" id="loginName" value="${CurrentUserBean.loginName }" />
								<input type="hidden" id="loginPassword" value="${CurrentUserBean.loginPassword }" />
								<input type="hidden" id="fullname" value="${CurrentUserBean.fullname }" />&nbsp;&nbsp;&nbsp;&nbsp;</span>
							
								
								<span class="glyphicon glyphicon-time" aria-hidden="true"></span>
								<span>&nbsp;&nbsp;登录时间：${currentDate }</span>
								
							</span>
						</td>
						<td style="width:4%;color:#000000;" align="left">
							<!--修改密码、注销-->
							<div class="dropdown" style="float:left;position:relative;left:3px;margin-top:5px">
								<button id="gear" class="btn btn-default dropdown-toggle" style="border:0px;border-radius:0;height:25px" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
									<span class="glyphicon glyphicon-cog" style="color:#000000"></span>
								</button>
								<ul id="gearSelect" class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenu1" style="min-width: 110px;border-radius:4px 4px 4px 4px">
									<li>
										<a onclick="updPassword()">
											<span  class="glyphicon glyphicon-edit" aria-hidden="true"></span>
											修改密码
										</a>
									</li>
									<li>
										<a onclick="logout()">
											<span class="glyphicon glyphicon-off" aria-hidden="true"></span>
											注销
										</a>
									</li>
								</ul>
							</div>
						</td>
					</tr>
				</table>
			</div>
		</div>
		<div class="row" style="width:100%;height:70px;background:#ffffff;margin-left: 5px;margin-right: 10px;">
			<div class="col-lg-12 col-md-12 col-sm-12 col-xs-18" style="border:0px solid #5479d7;height:40px">
				<!--主页菜单栏-->
				<div id="menuDiv" style="border:0px solid red;width:100%;height:50%;background:#0099cc;border-radius:6px">
				
				</div>
				<!-- <div id="menuDiv" style="border:0px solid red;width:100%;height:50%;background:#6D3353;border-radius:6px"></div> -->
				<!--导航路径-->
				<div style="border:0px solid red;width:100%;height:18px;font-weight: 700;font-size: 12px;padding-top:6px">

								<!-- <span id="tabBtn" class="glyphicon glyphicon-th-large" aria-hidden="true" style="cursor:pointer;margin-left:5px"></span> -->
								<img id="tabBtn" src="${basepath}image/win.png" style="cursor:pointer;width:18px;height: 18px;" />

										<span class="glyphicon glyph`icon-home" aria-hidden="true"></span>
										<a href="javascript:void()" onclick="chageFrame('index')">首页</a>

				</div>
			</div>
		</div>
		<div class="row" style="margin-left: 5px;margin-right: 3px;background: #ffffff;height:82%">
			<div class="col-lg-12 col-md-12 col-sm-12 col-xs-18" style="height:99.9%;text-align:center;border:0px solid #0099cc;">
				<div id="myframes" style="width: 100%;height: 100%;"></div>
				<div id="myframesDemo" style="display:none;">
					<iframe id="_" class="myframes" scrolling="no" src="" style="display:none;height:100%;width:100%;background:#ffffff;border:1px solid #e3e3e3; "></iframe>
				</div>
			</div>
		</div>
	</div>
	<div class="tabDiv" id="tabDiv">
		<div class="closeBtn">
			<button type="button" id="closeTabDiv" class="btn btn-default" aria-label="Left Align" style="color:#000000;border:0px;width:30px">
				<span class="glyphicon glyphicon-remove" aria-hidden="true"> </span>
			</button>
		</div>
		<div id="currentFrame" style="width:100%;height:100%;position:absolute;top:5%;left:0px;overflow-y:auto;"></div>
	</div>
	<div id="DivModel" style="display: none;">
		<div id="span_#ID#" style="display:block;float:left ;margin:10 25 10 25;text-align: center;">
			<div class="blockDiv bcolor" onclick="chageFrame('#ID#')" style="width:100px;height:80px;background-color: #COLOR#"  onmouseover="mouseover(this)" onmouseout="mouseout(this)">
				<%-- <p><img alt="" src="${bastpath }image/system/userManage.gif"></p> --%>
				<br/>
				<span style="font-size: 12x;color:white;width:100px;height: 38px;display:table-cell;text-align:center;vertical-align:middle">#NAME#</span>
				<div class="blockClose" onclick="colseFrame('#ID#')">
					<button type="button" id="userManage" class="btn btn-default" aria-label="Left Align" style="color:#000000;border:0px;width:30px;display:none;background:none">
						<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
					</button>
				</div>
				
			</div>
		</div>
	</div>
</body>
</html>
